<?php
namespace plugins\log\model;
use think\Model;


class SysLogsModel extends Model{
    
    protected $autoWriteTimestamp = true;
    protected $createTime = "add_time";
    protected $updateTime = false;
    
    
    public function setParamsAttr( $value , $data )
    {
        return empty( $value ) ? '' : json_encode( $value , JSON_UNESCAPED_UNICODE);
    }
    
    public function getUserTypeAttr( $value )
    {
        $arr = [ "-","用户" , "管理员" ];
        return $arr[ $value ];
    }
    public function getStatusAttr( $value )
    {
        return ($value==200 || $value == 1)? 1 : 0;
    }
    public function getStatusTextAttr( $value , $data )
    {
        return ($data['status']==200 || $data['status'] == 1)?'请求成功':'请求失败';
    }
    
    public function getUidTextAttr( $value , $data )
    {
        return empty( $data['uid'] )?'-': $data['uid'];
    }
    public function getAddTimeAttr( $value , $data )
    {
        return date( 'Y/m/d H:i:s' , $value );
    }
}